package com.googlecode.gaal.preprocess.impl;

import java.util.Set;

import com.googlecode.gaal.preprocess.api.Normalizer;

public class StopWordRemover implements Normalizer<String> {

    private final Set<String> stopWords;
    private final Normalizer<String> normalizer;

    public StopWordRemover(Set<String> stopWords, Normalizer<String> normalizer) {
        this.stopWords = stopWords;
        this.normalizer = normalizer;
    }

    @Override
    public String normalize(String token) {
        token = normalizer.normalize(token);
        return (stopWords.contains(token) ? null : token);
    }
}
